/*
 * To change this template, choose Tools | Templates
 * and open the template in the editor.
 */
package Frame;

import jPlay.Animation;
import jPlay.GameImage;
import jPlay.Keyboard;
import jPlay.Mouse;
import jPlay.Sprite;
import jPlay.Window;
import java.awt.Font;
import java.awt.TextField;

/**
 *
 * @author wagner
 */
public class Exemplo15 extends javax.swing.JFrame{
    public Animation criarBotaoVerde(){
        Animation botao = new Animation("verde.png");
        botao.setPosition(1078,120);
        botao.setTimeChangeFrame(100);
            return botao;
    }
    
    public TextField criarTextFildeDado1(){
         TextField j = new TextField();
         j.setBounds(1078, 46, 100, 30);
         j.setFont(new Font("Calibri", Font.PLAIN, 18));
         return j;     
    }
     public TextField criarTextFildeDado2(){
         TextField b = new TextField();
         b.setBounds(1078, 90, 100, 30);
         b.setFont(new Font("Calibri", Font.PLAIN, 18));
         return b;
        
    }
    public Exemplo15(){
    
    
        Window janela = new Window(1500, 730);
        Keyboard key = janela.getKeyboard();
        Mouse mouse = janela.getMouse();
        GameImage backGroud = new GameImage("Tabuleiro2.png");
      
        Exemplo15 t = new Exemplo15();
        Animation botao2 = t.criarBotaoVerde();
        //JtextFilde e adicionar na tela.
        TextField j = t.criarTextFildeDado1();
        TextField b = t.criarTextFildeDado2();
      
        
        janela.add(j);  
        janela.add(b);
        
        Sprite o = new Sprite("vermelho.png");
        o.setPosition(400, 400); 
         
         
        boolean clicouNoBotao= false;
        while(true){
            backGroud.draw();
            o.draw();
            botao2.draw();
            janela.display();
            
        System.out.println("fora"+clicouNoBotao);
      
       if(mouse.isOverObject(botao2) && mouse.isLeftButtonPressed()){
          clicouNoBotao = true; 
          System.out.println("dentro"+clicouNoBotao);
       }
      if(clicouNoBotao){
          botao2.runAnimation();
        String text = j.getText(); 
        String textt = b.getText();
        System.out.println(text + textt);
          o.moveToDown();
      }
          
      if(botao2.isAnimationFinished()){
          clicouNoBotao=false;
          botao2.reset();
      }
      }
         
        
    }

   
    
    public static void main(String args[]){
       
}
    }
